keyboard messages
Keyboard messages contain the window number of the window that was selected when the keyboard event was detected.

  arguments v0, v1, v2, v3, r0, r1 contain: x, y, state, time, 0, grid.

x,y
x,y contain the position of the mouse cursor in the local coordinates of the specified grid at the time the keyboard event was detected.  If x or y is negative, the mouse cursor was outside the specified grid, or the mouse coordinates were unavailable.

state
state contains the state of the keyboard when the keyboard event was detected, and reflects the new state of the keyboard.

bit 00 - 15 : Character code of some kind (see bits 20-21)
bit 16 - 23 : Keyboard "mode" keys (16=Shift, 17=Control, 18=Alt)
bit 24 - 31 : Virtual Key Code

bit 16 = 1  : Shift key was down when the keyboard event occured.
bit 17 = 1  : Control key was down when the keyboard event occured.
bit 18 = 1  : Alt key was down when the keyboard event occured.
bit 19      : Reserved (right Alt key down?)
bit 20 - 21 : Type of character code in Bit 00 - 15 (see below)
bit 20 - 21 : 0 = Bit 00 - 15 = Virtual Key Code (8-bits)
            : 1 = Bit 00 - 15 = ASCII character (8-bits)
            : 2 = Bit 00 - 15 = WIDE character (16-bits)
            : values 3 to 7 are reserved
bit 22      : Reserved (right Shift key down?)
bit 23      : Reserved (right Control key down?)

time
time contains the system millisecond time that the keyboard event was detected. time is not related to time of day.  It is simply a free running millisecond timer that computer systems usually initialize to zero when they are started.

keyboard message examples
key   24-31 20-21  18  17  16  0-15  "."  mode key states, key event
Down   97     1    0   0   0    97    a   None down, "a" down
Up     97     0    0   0   0    97    -   None down, "a" up
Down   65     1    0   0   1    65    A   Shift down, "a" down
Up     65     0    0   0   1    65    -   Shift down, "a" up
Down   65     0    0   1   0    65    ^A  Ctl down, "a" down
Down   65     0    0   1   1    65    ?   Ctl+Shift down, "a" down
Down   65     0    1   0   0    65    ?   Alt down, "a" down
Down   65     0    1   0   1    65    ?   Alt+Shift down, "a" down
Down   65     0    1   1   0    65    ?   Alt+Ctl down, "a" down
Down   65     0    1   1   1    65    ?   Alt+Ctl+Shift down, "a" down
Up     65     0    1   1   1    65    ?   Alt+Ctl+Shift down, "a" up
Down   39     0    0   1   0    39   Left Ctl down, LeftArrow press